﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	内容管理【总览】
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
	<script type="text/javascript" language="javascript">
	    $(function () {
	        $('#mainGrid').datagrid({
	            title: '内容一览',
	            url: '<%=Url.Action("List")%>',
	            iconCls: 'icon-edit',
	            singleSelect: false,
	            method: 'get',
                cache:false,
	            width: 1000,
	            height: 'auto',
	            fitColumns: false,
	            idField: 'ID',
	            pagination: true,
	            rownumbers: false,
	            columns: [[
                        { field: 'ID', title: '操作', width: 65, align: 'center', formatter: operatorFormatter },
				        { field: 'Name', title: '标题', width: 150, align: 'center' },
				        { field: 'GUID', title: 'GUID', width: 80, align: 'center' },
				        { field: 'ResTypeID', title: '类型', width: 60, align: 'center', formatter: getComboboxFormatter(resType) },
				        { field: 'SectionName', title: '所属栏目', width: 80, align: 'center' },
				        { field: 'FilePath', title: '文件路径', width: 200, align: 'center' },
				        { field: 'StatusTypeID', title: '状态', width: 80, align: 'center', formatter: getComboboxFormatter(statusType) },
                        { field: 'CreatorName', title: '创建者', width: 80, align: 'center' },
                        { field: 'CDateString', title: '创建日', width: 80, align: 'center' },
				        { field: 'UDateString', title: '更新日', width: 80, align: 'center' }
			        ]],
                toolbar: [
                    {
                        text: '删除选中',
                        iconCls: 'icon-remove',
                        handler: function () {
                             
                        }
                    }, '-', {
                        text: '删除全部',
                        iconCls: 'icon-remove',
                        handler: function () {

                        }
                    }
                ]
	        }); //grid完毕

	        //资源类型改变时
	        $('#resTypeSel').combobox({ 
                onChange: function (nw, od) {
	                $('#mainGrid').datagrid("reload", {id:nw, t:(new Date()).getTime()});
	            } 
	        });
	    });  //初始化函数完毕

	    //
	    //操作列格式化函数
        //
	    function operatorFormatter(value) {
	        return value +
	               '&nbsp;<input onclick="openEditWin(this,' + value + ');" type="button" class="icon-edit" style="width:20px;" val="编辑"/>' +
                   '<input onclick="deleteRow(' + value + ');" type="button" class="icon-cut" style="width:20px;" val="删除"/>' +
                   ((value < 0) ? '*' : '　');
	    }
	    $().ready(function () {

	    });

        var urlPair = {
            '<%=ResType.Article.ID %>':'<%=Url.Action("EditArticle")%>/',
            '<%=ResType.File.ID %>':'<%=Url.Action("EditFiles")%>/',
            '<%=ResType.Picture.ID %>':'<%=Url.Action("EditPictures")%>/',
            '<%=ResType.Media.ID %>':'<%=Url.Action("EditMedias")%>/',
            '<%=ResType.Product.ID %>':'<%=Url.Action("EditProduct")%>/'
        };

	    function openEditWin(link, id) {
	        var rows = $('#mainGrid').datagrid('getRows');
            var row = null;
            for(var i = 0; i < rows.length; i++){
                if(rows[i].ID == id){
                    row = rows[i];
                }
            }
            if(row == null) return;

            if(row.ResTypeID == <%=ResType.Article.ID %>){
                parent.window.openSubWindow("编辑文章[" + id + "]", '<%=Url.Action("EditArticle")%>/' + id);
            }else if(row.ResTypeID == <%=ResType.Picture.ID %>){
                parent.window.openSubWindow("编辑图片[" + id + "]", '<%=Url.Action("EditPictures")%>/' + id);
            }else if(row.ResTypeID == <%=ResType.Product.ID %>){
                parent.window.openSubWindow("编辑产品[" + id + "]", '<%=Url.Action("EditProduct")%>/' + id);
            }
        }

	    function openWin(title, url) {
	        parent.window.openSubWindow(title, url);
	    }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="BodyContent" runat="server">
    <div class="demo-info">
		<div class="demo-tip icon-tip"></div>
		<div>
            <label for="resTypeSel">类型筛选</label>
            <input id="resTypeSel" class="easyui-combobox"
			    name="resTypeID"
                value='<%=ResType.None.ID %>'
			    url='<%=Url.Action("ResType", "Dropdown")%>'
			    valueField="value" 
			    textField="text"
                autocomplete="false"
			    panelHeight="auto"/>
            <a href="javascript:void(0)" id="newRes" class="easyui-splitbutton" plain="false" 
                menu="#newResMenu" iconCls="icon-add" 
                onclick="javascript:alert('edit')">新建...</a>
            <div id="newResMenu" style="width:150px;">  
		        <div onclick="openWin('新建文章','<%=Url.Action("EditArticle")%>')"><%=ResType.Article.Name%></div>
		        <div><%=ResType.Picture.Name%></div>
		        <div><%=ResType.Media.Name%></div>
		        <div><%=ResType.Product.Name%></div>
		        <div><%=ResType.File.Name%></div>
		        <div><%=ResType.Folder.Name%></div>
           </div>
        </div>
	</div>
    <div class="operator"></div>
    <table id="mainGrid"></table>
    <div class="demo-info">
		<div class="demo-tip icon-tip"></div>
		<div>
            <ul>
                <li>此画面管理网站所有资源文件，您也可以按照资源类型进行查看。</li>
            </ul>
        </div>
	</div>
</asp:Content>

